package study.edumanagesystemspringboot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import study.edumanagesystemspringboot.entity.Admin;

import study.edumanagesystemspringboot.mapper.AdminMapper;
import study.edumanagesystemspringboot.service.IAdminService;

import java.util.List;

/**
 * @author zouran
 * createDate：2023/12/30  13:52
 */
@Service
public class IAdminServiceImp extends ServiceImpl<AdminMapper, Admin> implements IAdminService {
    private final AdminMapper adminMapper;

    public IAdminServiceImp(AdminMapper adminMapper) {
        this.adminMapper = adminMapper;
    }

    @Override
    public Admin checkLogIn(String accountNumber, String password) {
        // 创建 QueryWrapper
        QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();

        // 设置查询条件
        queryWrapper.eq("account_number", accountNumber)
                .eq("password", password)
                .select("identify", "head_sculpture", "account_name");

        // 执行查询
        return adminMapper.selectOne(queryWrapper);
    }

    @Override
    public Admin checkPermission(String accountNumber) {
        // 创建 QueryWrapper
        QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();

        // 设置查询条件
        queryWrapper.eq("account_number", accountNumber)
                .select("identify");

        // 执行查询
        return adminMapper.selectOne(queryWrapper);
    }
}
